using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using EcsSiteDSTableAdapters;

namespace SiteECSWeb
{
    [DataObject]
    public class EmbassyBLL
    {
        private EmbassyTableAdapter _EmbassyAdapter = null;

        protected EmbassyTableAdapter EmbassyAdapter
        {
            get
            {
                if (_EmbassyAdapter == null)
                {
                    _EmbassyAdapter = new EmbassyTableAdapter();
                }
                return _EmbassyAdapter;
            }
        }

        #region SelectEmbassy
        // Get Embassy Data//
        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public EcsSiteDS.EmbassyDataTable GetEmbassyRowRank()
        {
            return EmbassyAdapter.GetEmbassyRowRankData();
        }

        // Get Embassy By Embassy ID//
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmbassyDataTable GetEmbassyByEmbassId(int Embass_ID)
        {
            return EmbassyAdapter.GetEmbassyDataByEmbassyID(Embass_ID);
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmbassyDataTable GetEmbassyByCityId(int City_id)
        {
            return EmbassyAdapter.GetEmbassyDataByCityId(City_id);
        }
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmbassyDataTable GetEmbassyByCuntryId(string CuntryId)
        {
            return EmbassyAdapter.GetEmbassyDataByCuntryId(CuntryId);
        }
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmbassyDataTable GetEmbassyByCuntrynmen(string Cuntry_nmen)
        {
            return EmbassyAdapter.GetEmbassyDataByCuntrynmen(Cuntry_nmen);
        }


        #endregion

        #region InsertEmbassy
        [DataObjectMethodAttribute(DataObjectMethodType.Insert, true)]
        public bool AddEmbassy(string Embass_AmbassdorNamar,
            string Embass_AmbTitlesar, string Embass_Addressar,
            string Embass_AmbassdorNamen, string Embass_AmbTitlesen,
            string Embass_Addressen, string Embass_Phone, string Embass_Phone2,
            string Embass_Fax2, string Embass_Fax, string Embass_Email,
            string Embass_Website, string Embass_Types, int City_id)
        {
            EcsSiteDS.EmbassyDataTable EmbassyTable = new EcsSiteDS.EmbassyDataTable();
            EcsSiteDS.EmbassyRow EmbassyRow = EmbassyTable.NewEmbassyRow();

            if (string.IsNullOrEmpty(Embass_AmbTitlesar)) EmbassyRow.SetEmbass_AmbTitlesarNull(); else EmbassyRow.Embass_AmbTitlesar = Embass_AmbTitlesar;
            if (string.IsNullOrEmpty(Embass_Addressar)) EmbassyRow.SetEmbass_AddressarNull(); else EmbassyRow.Embass_Addressar = Embass_Addressar;
            if (string.IsNullOrEmpty(Embass_AmbassdorNamen)) EmbassyRow.SetEmbass_AmbassdorNamenNull(); else EmbassyRow.Embass_AmbassdorNamen = Embass_AmbassdorNamen;
            if (string.IsNullOrEmpty(Embass_AmbTitlesen)) EmbassyRow.SetEmbass_AmbTitlesenNull(); else EmbassyRow.Embass_AmbTitlesen = Embass_AmbTitlesen;
            if (string.IsNullOrEmpty(Embass_Addressen)) EmbassyRow.SetEmbass_AddressenNull(); else EmbassyRow.Embass_Addressen = Embass_Addressen;
            if (string.IsNullOrEmpty(Embass_Phone2)) EmbassyRow.SetEmbass_Phone2Null(); else EmbassyRow.Embass_Phone2 = Embass_Phone2;
            if (string.IsNullOrEmpty(Embass_Fax2)) EmbassyRow.SetEmbass_Fax2Null(); else EmbassyRow.Embass_Fax2 = Embass_Fax2;
            if (string.IsNullOrEmpty(Embass_Website)) EmbassyRow.SetEmbass_WebsiteNull(); else EmbassyRow.Embass_Website = Embass_Website;
            if (string.IsNullOrEmpty(Embass_Types)) EmbassyRow.SetEmbass_TypesNull(); else EmbassyRow.Embass_Types = Embass_Types;


            EmbassyRow.Embass_AmbassdorNamar = Embass_AmbassdorNamar;
            EmbassyRow.Embass_Phone = Embass_Phone;
            EmbassyRow.Embass_Fax = Embass_Fax;
            EmbassyRow.Embass_Email = Embass_Email;
            EmbassyRow.City_id = City_id;

            EmbassyTable.AddEmbassyRow(EmbassyRow);

            int rowsAffected = EmbassyAdapter.Update(EmbassyTable);

            return rowsAffected == 1;



        }

        #endregion

        #region UpdateEmbassy

        [DataObjectMethodAttribute(DataObjectMethodType.Update, true)]
        public bool UpdateEmbassy(string Embass_AmbassdorNamar,
            string Embass_AmbTitlesar, string Embass_Addressar,
            string Embass_AmbassdorNamen, string Embass_AmbTitlesen,
            string Embass_Addressen, string Embass_Phone, string Embass_Phone2,
            string Embass_Fax2, string Embass_Fax, string Embass_Email,
            string Embass_Website, string Embass_Types, int City_id, int Embass_ID)
        {
            EcsSiteDS.EmbassyDataTable EmbassyTable = EmbassyAdapter.GetEmbassyDataByEmbassyID(Embass_ID);
            if (EmbassyTable.Count == 0)
            {
                return false;
            }
            EcsSiteDS.EmbassyRow EmbassyRow = EmbassyTable[0];

            if (string.IsNullOrEmpty(Embass_AmbTitlesar)) EmbassyRow.SetEmbass_AmbTitlesarNull(); else EmbassyRow.Embass_AmbTitlesar = Embass_AmbTitlesar;
            if (string.IsNullOrEmpty(Embass_Addressar)) EmbassyRow.SetEmbass_AddressarNull(); else EmbassyRow.Embass_Addressar = Embass_Addressar;
            if (string.IsNullOrEmpty(Embass_AmbassdorNamen)) EmbassyRow.SetEmbass_AmbassdorNamenNull(); else EmbassyRow.Embass_AmbassdorNamen = Embass_AmbassdorNamen;
            if (string.IsNullOrEmpty(Embass_AmbTitlesen)) EmbassyRow.SetEmbass_AmbTitlesenNull(); else EmbassyRow.Embass_AmbTitlesen = Embass_AmbTitlesen;
            if (string.IsNullOrEmpty(Embass_Addressen)) EmbassyRow.SetEmbass_AddressenNull(); else EmbassyRow.Embass_Addressen = Embass_Addressen;
            if (string.IsNullOrEmpty(Embass_Phone2)) EmbassyRow.SetEmbass_Phone2Null(); else EmbassyRow.Embass_Phone2 = Embass_Phone2;
            if (string.IsNullOrEmpty(Embass_Fax2)) EmbassyRow.SetEmbass_Fax2Null(); else EmbassyRow.Embass_Fax2 = Embass_Fax2;
            if (string.IsNullOrEmpty(Embass_Website)) EmbassyRow.SetEmbass_WebsiteNull(); else EmbassyRow.Embass_Website = Embass_Website;
            if (string.IsNullOrEmpty(Embass_Types)) EmbassyRow.SetEmbass_TypesNull(); else EmbassyRow.Embass_Types = Embass_Types;

            EmbassyRow.Embass_AmbassdorNamar = Embass_AmbassdorNamar;
            EmbassyRow.Embass_Phone = Embass_Phone;
            EmbassyRow.Embass_Fax = Embass_Fax;
            EmbassyRow.Embass_Email = Embass_Email;
            EmbassyRow.City_id = City_id;


            int rowsAffected = EmbassyAdapter.Update(EmbassyRow);

            return rowsAffected == 1;
        }

        #endregion

        #region DeleteEmbassy

        [DataObjectMethodAttribute(DataObjectMethodType.Delete, true)]
        public bool DeleteEmbassy(int Embass_ID)
        {
            int rowsAffected = EmbassyAdapter.Delete(Embass_ID);
            return rowsAffected == 1;
        }

        #endregion
    }

}
